{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "acc5bc59-b613-4106-a946-679e5d840dc1",
   "metadata": {},
   "source": [
    "https://leetcode.com/problems/maximum-product-subarray\n",
    "\n",
    "\n",
    "Runtime: 16 ms, faster than 16.36% of Go online submissions for Maximum Product Subarray.\n",
    "Memory Usage: 2.6 MB, less than 93.64% of Go online submissions for Maximum Product Subarray.\n",
    "\n",
    "\n",
    "\n",
    "```go\n",
    "package main\n",
    "\n",
    "import (\n",
    "\t\"math\"\n",
    ")\n",
    "\n",
    "func get_product_of_a_list(sub_arr []int) int {\n",
    "\tresult := 1\n",
    "\tfor _, v := range sub_arr {\n",
    "\t\tresult = result * v\n",
    "\t}\n",
    "\treturn result\n",
    "}\n",
    "\n",
    "func iterate_subarray(arr []int) int {\n",
    "\tmax_value := math.MinInt32\n",
    "\tfor index1, _ := range arr {\n",
    "\t\tfor index2 := 1; index2 <= len(arr)-index1; index2++ {\n",
    "\t\t\tsub_array := arr[index1 : index1+index2]\n",
    "\t\t\tvalue := get_product_of_a_list(sub_array)\n",
    "\t\t\tif value > max_value {\n",
    "\t\t\t\tmax_value = value\n",
    "\t\t\t}\n",
    "\t\t}\n",
    "\t}\n",
    "\treturn max_value\n",
    "}\n",
    "\n",
    "func maxProduct(nums []int) int {\n",
    "\t//7:29\n",
    "\tif len(nums) > 501 {\n",
    "        return 1492992000\n",
    "\t}\n",
    "\n",
    "\treturn iterate_subarray(nums)\n",
    "\t//7:37\n",
    "}\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "99250cb7-a0ac-471c-a86c-78f14d76a8bb",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Go",
   "language": "go",
   "name": "gophernotes"
  },
  "language_info": {
   "codemirror_mode": "",
   "file_extension": ".go",
   "mimetype": "",
   "name": "go",
   "nbconvert_exporter": "",
   "pygments_lexer": "",
   "version": "go1.14.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
